﻿
using System;

using ServiceStack.Text;

namespace Monitor.Models.Core
{
    public class Logger:Interfaces.ILogger
    {
        private log4net.ILog _logger ;
        public Logger(log4net.ILog logger)
        {
            _logger = logger;
        }
        public void Fatal(object message,System.Exception exception)
        {
            _logger.Fatal(string.Format("{0} - {1}", message,exception.Message),exception);
        }
        public void Error(object message, System.Exception exception)
        {
            _logger.Error(string.Format("{0} - {1}", message, exception.Message), exception);
        }
        public void Info(object message, System.Exception exception)
        {
            _logger.Info(string.Format("{0} - {1}", message, exception.Message), exception);
        }
        public void Debug(object message, System.Exception exception)
        {
            _logger.Debug(string.Format("{0} - {1}", message, exception.Message), exception);
        }

        public void Fatal(object message)
        {
            _logger.Fatal(message);
        }
        public void Error(object message)
        {
            _logger.Error(message);
        }
        public void Info(object message)
        {
            _logger.Info(message);
        }
        public void Debug(object message)
        {
            _logger.Debug(message);
        }


        public void RegisterOperation(System.Security.Principal.IPrincipal User, 
            System.Web.Http.Controllers.HttpControllerContext controllerContext,
            object model)
        {
            
        }

        public void Fatal(System.Web.Http.Controllers.HttpControllerContext controllerContext, System.Exception exception)
        {
            this.Fatal(string.Format("{0}   {1}   {2}   {3}",
                    controllerContext.Controller.ToString(),
                    controllerContext.Request.Method.ToString(),
                    controllerContext.Request.RequestUri.AbsoluteUri.ToString(),
                    exception.Message));
        }

        public void Error(System.Web.Http.Controllers.HttpControllerContext controllerContext, System.Exception exception)
        {
            this.Error(string.Format("{0}   {1}   {2}   {3}",
                    controllerContext.Controller.ToString(),
                    controllerContext.Request.Method.ToString(),
                    controllerContext.Request.RequestUri.AbsoluteUri.ToString(),
                    exception.Message));
        }

        public void Info(System.Web.Http.Controllers.HttpControllerContext controllerContext, System.Exception exception)
        {
            this.Info(string.Format("{0}   {1}   {2}   {3}",
                    controllerContext.Controller.ToString(),
                    controllerContext.Request.Method.ToString(),
                    controllerContext.Request.RequestUri.AbsoluteUri.ToString(),
                    exception.Message));
        }
    }
}